package com.wei.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.wei.enums.EnabledEnum;
import com.wei.enums.BannerIsBigEnum;
import com.wei.model.BannerDO;
import com.wei.result.R;
import com.wei.service.IBannerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 轮播图表 前端控制器
 * </p>
 *
 * @author 蔡徐坤
 * @since 2025-07-28
 */
@RestController
@RequiredArgsConstructor
@Api(tags = "轮播图)")
@RequestMapping("/api/banner")
public class BannerController {

    private final IBannerService bannerService;

    @ApiOperation("查询大图列表")
    @GetMapping("/big/list")
    public R<List<BannerDO>> getBigBanners() {
        List<BannerDO> res = bannerService.list(new LambdaQueryWrapper<BannerDO>()
                .eq(BannerDO::getIsBig, BannerIsBigEnum.BIG.getCode())
                .eq(BannerDO::getEnabled, EnabledEnum.ENABLED.getCode()));
        return R.ok(res);
    }

    @ApiOperation("查询小图列表")
    @GetMapping("/small/list")
    public R<List<BannerDO>> getSmallBanners() {
        List<BannerDO> res = bannerService.list(new LambdaQueryWrapper<BannerDO>()
                .eq(BannerDO::getIsBig, BannerIsBigEnum.SMALL.getCode())
                .eq(BannerDO::getEnabled, EnabledEnum.ENABLED.getCode()));
        return R.ok(res);
    }

}
